package com.aba.cms.student;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class EnrollmentService {
    public static void enrollStudent(Student student, Course course) {
        Connection connection = DBUtil.getConnection();
        String sql = "INSERT INTO enrollments (student_id, course_id) VALUES (?,?)";
        try {
            PreparedStatement statement = connection.prepareStatement(sql);
            statement.setInt(1, student.getStudentId());
            statement.setInt(2, course.getCourseId());
            statement.executeUpdate();
            statement.close();
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static List<Enrollment> getEnrollmentsByStudent(Student student) {
        // 这里可以实现根据学生ID查询选课记录的逻辑
        // 暂时省略具体实现，可参照前面的数据库操作方式编写
        return null;
    }
}